const { min } = require('lodash');
const { unix } = require('moment');
const moment = require('moment')
const date = moment();
console.log('date:' + date);    // 当前时间戳(毫秒)

const now = new Date();         // Thu Apr 21 2022 16:44:13 GMT+0800 (中国标准时间)
console.log('now:' + now);

const time = moment().unix();   // 当前时间戳(秒)
console.log('time:' + time);

const times = moment().format('YYYY-MM-DD HH:mm:ss'); // 设置打印出得日期格式 例如：2022-04-21 16:47:04
console.log('times:' + times);

const unix1 = moment.unix(time); // 当前时间戳(毫秒)  moment.unix(Number)  参数为 时间戳(秒)

console.log('unix:' + unix1);  
const year = unix1.year()
const month = unix1.month()
console.log('year:' + year);    // 2022
console.log('month:' + month);  // 3 

const par = parseInt(new Date(times) / 1000, 10); // 当前时间戳(秒)
console.log('par:' + par);

// 设置为最近的 5 分钟时间戳
const minute =time - time % 300;
console.log('minute:' + minute);
const date_format = moment(minute * 1000).format('YYYY-MM-DD HH:mm:ss');
console.log('date_format:' + date_format);

const d = Date.now();
const create = Math.ceil(Date.now() / 1000);
console.log('d:' + d);
console.log('create:' + create);

const endTime1 = 1320050313;
const date1 = moment(endTime1 * 1000).format('YYYY-MM-DD HH:mm:ss')
console.log('date1:' + date1);

const endTime2 = 1635694642;
const date2 = moment(endTime2 * 1000).format('YYYY-MM-DD HH:mm:ss')
console.log('date2:' + date2);
